package com.newzqxq.koalamoney.ui.activity;

import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.newzqxq.koalamoney.R;
import com.newzqxq.koalamoney.common.BaseActivity;
import com.newzqxq.koalamoney.entity.BorrowInfoBean;
import com.newzqxq.koalamoney.ui.adapter.BorrowInfoAdapter;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnLoadmoreListener;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 借款信息
 * Created by ZQXQ-Developer on 2017/7/18.
 */

public class BorrowInfoActivity extends BaseActivity {
    @BindView(R.id.title_relative_back)
    RelativeLayout rlBack;

    @BindView(R.id.title_mid_tv)
    TextView tvTitle;


    @BindView(R.id.refreshLayout)
    RefreshLayout mRefreshLayout;
    @BindView(R.id.recyclerView)
    RecyclerView recyclerView;
    List<BorrowInfoBean> data = new ArrayList<>();
    BorrowInfoAdapter adapter;

    @Override
    protected int getContentViewId() {
        return R.layout.ui_borrow_info;
    }

    @Override
    protected void initData() {

        for (int i = 1; i < 20; i++) {
            BorrowInfoBean bean = new BorrowInfoBean("1" + i + "日理财2017090600" + i + "期", "非非/18岁", i + "00.00", "1" + i, "生活消费");
            data.add(bean);
        }

        adapter = new BorrowInfoAdapter(data, this);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        recyclerView.setItemAnimator(new DefaultItemAnimator());
        recyclerView.setAdapter(adapter);
        mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshlayout) {
                refreshlayout.finishRefresh(2000);
            }
        });
        mRefreshLayout.setOnLoadmoreListener(new OnLoadmoreListener() {
            @Override
            public void onLoadmore(RefreshLayout refreshlayout) {
                adapter.notifyDataSetChanged();
                mRefreshLayout.finishLoadmore();
            }
        });
    }

    @Override
    protected void initView() {
        tvTitle.setText(R.string.borrow_info);
    }

    @Override
    protected void initListener() {

    }

    @Override
    protected void clearMemory() {

    }


    @OnClick({R.id.title_relative_back})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.title_relative_back:
                finish();
                break;
        }
    }
}
